#include <bits/stdc++.h>

#define eb emplace_back
#define ep emplace
#define fi first
#define se second
#define in read<int>()
#define lin read<ll>()
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using veg = vector < pii >;

template < typename T > T read() {
	T x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-', ch = getchar();
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

template < typename T > void chkmax(T &x, const T &y) { x = x > y ? x : y; }
template < typename T > void chkmin(T &x, const T &y) { x = x < y ? x : y; }

const int N = 1e6 + 10;
constexpr int mod = 998244353;
//constexpr int mod = 1e9 + 7;

int reduce(int x) {
	if(x < 0) x += mod;
	if(x >= mod) x -= mod;
	return x;
}

template < typename T > T qp(T x, ll t) { T res = 1; for(; t; t >>= 1, x *= x) if(t & 1) res *= x; return res; }

struct Z { // modint
	int x;
	Z(int x = 0) : x(reduce(x)) {}
	Z(ll x) : x(reduce(x % mod)) {}
	Z operator -() const { return Z(reduce(mod - x)); }
	int val() const { return x; }
	Z inv() const { assert(x); return qp(*this, mod - 2); }
	Z &operator += (const Z &t) { x = reduce(x + t.x); return *this; }
	Z &operator -= (const Z &t) { x = reduce(x - t.x); return *this; }
	Z &operator *= (const Z &t) { x = (ll)x * t.x % mod; return *this; }
	Z &operator /= (const Z &t) { return *this *= t.inv(); }
	friend Z operator + (const Z &a, const Z &b) { Z res = a; res += b; return res; }
	friend Z operator - (const Z &a, const Z &b) { Z res = a; res -= b; return res; }
	friend Z operator * (const Z &a, const Z &b) { Z res = a; res *= b; return res; }
	friend Z operator / (const Z &a, const Z &b) { Z res = a; res /= b; return res; }
	friend ostream & operator << (ostream &out, const Z &x) {
		out << x.val();
		return out;
	}
};

using vec = vector < ll >;

int t[N], top;
ll f[10][100][2], g[100][2];

vec calc(int x) {
	if(x == 0) {
		vec ret; rep(i, 0, 9) ret.eb(i == 0);
		return ret;
	}
	top = 0; while(x > 0) t[++top] = x % 10, x /= 10;
	reverse(t + 1, t + top + 1);
	g[0][1] = 1;
	rep(i, 1, top) {
		rep(t, 0, 1) rep(j, 0, 9) f[j][i][t] = 0, g[i][t] = 0;
		rep(t, 0, 1) if(g[i - 1][t]) {
			int up = t ? ::t[i] : 9;
			rep(k, 0, up) {
				g[i][t & k == up] += g[i - 1][t];
				rep(j, 0, 9)
					f[j][i][t & k == up] += g[i - 1][t] * (j == k) + f[j][i - 1][t];
			}
		}
	}
	vec ret; rep(j, 0, 9) ret.eb(f[j][top][0] + f[j][top][1]);
	return ret;
}

vec operator - (vec a, vec b) {
	vec c; 
	rep(j, 0, 9) c.eb(a[j] - b[j]);
	return c;
}

Z tcalc(vec c) {
	if(c[0]) return 0;
	Z ret = 1;
	rep(i, 2, 9) ret = ret * qp(Z(i), c[i]);
	return ret;
}

int main() {
#ifdef YJR_2333_TEST
	freopen("1.in", "r", stdin);
#endif
	int T = in;
	while(T--) {
		int l = in, r = in;
		vec a = calc(l - 1), b = calc(r);
		vec c = b - a;
		rep(i, 0, 9) cerr << a[i] << " "; cerr << endl;
		rep(i, 0, 9) cerr << b[i] << " "; cerr << endl;
		rep(i, 0, 9) cerr << c[i] << " "; cerr << endl;
		printf("%d\n", tcalc(c).val());
	}
	return 0;
}
